package com.app.teaware.user;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.app.teaware.basis.Constants;
import com.app.teaware.bean.LoginBean;
import com.app.teaware.bean.MenuBean;
import com.app.teaware.bean.UserInfoBean;
import com.app.teaware.login.LoginActivity;
import com.app.teaware.R;
import com.app.teaware.home.HomeBaseActivity;
import com.app.teaware.other.PdfScanActivity;
import com.app.teaware.set.AboutUsActivity;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.uuzuche.lib_zxing.activity.CodeUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import my.ActivityTool;
import my.MySharedPreferences;
import my.SystemParamsUtils;
import my.http.MyHttpListener;
import my.http.MyHttpUtils;
import my.http.MyParams;


public class UserIndexActivity extends HomeBaseActivity {


    @BindView(R.id.tv_name)
    TextView textName;
    @BindView(R.id.tv_content)
    TextView textContent;
    @BindView(R.id.img_photo)
    ImageView img_photo;


    @BindView(R.id.text_version_name)
    TextView text_version_name;
    @BindView(R.id.img_qr)
    ImageView img_qr;


    @Override
    public void initViews() {
        setContentView(R.layout.user_index_activity);
        super.initViews();
        setTitleBg(R.color.transparent);
        ((TextView) findViewById(R.id.base_title_text)).setTextColor(getResources().getColor(R.color.white));
        setTitle("我的");

    }

    @Override
    public void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
        MySharedPreferences mSp = new MySharedPreferences(this);
        textName.setText("");
        textContent.setText("" + mSp.getUser());
        text_version_name.setText("v" + SystemParamsUtils.getAppVersonName(mContext));
    }


    @Override
    protected void onResume() {
        super.onResume();
//        getImmersionBar().statusBarDarkFont(true,0.5f);
//        getImmersionBar().statusBarDarkFont(true).init();
    }

    @Override
    public void onDoubleClick() {
        super.onDoubleClick();
        if(isFinishing())return;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }



    @OnClick(R.id.btn_out)
    void logout() {
        new QMUIDialog.MessageDialogBuilder(mContext).setMessage("退出当前账号？").addAction("取消", new QMUIDialogAction.ActionListener() {
            @Override
            public void onClick(QMUIDialog dialog, int index) {
                dialog.dismiss();
            }
        }).addAction(0, "立即退出", QMUIDialogAction.ACTION_PROP_NEGATIVE, new QMUIDialogAction.ActionListener() {
            @Override
            public void onClick(QMUIDialog dialog, int index) {
                dialog.dismiss();
                LoginActivity.toLoginAllClear(mContext);
            }
        }).create().show();
    }



    private static final int REQUEST_QRCODE = 11;

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }

    @OnClick(R.id.view_qrcode)
    void qrcode() {
//        Resources r = mContext.getResources();
//        Uri uri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
//                + r.getResourcePackageName(R.drawable.qr_code) + "/"
//                + r.getResourceTypeName(R.drawable.qr_code) + "/"
//                + r.getResourceEntryName(R.drawable.qr_code));
//
//        LogUtil.i("--uri---"+uri.toString());
//        PhotoScanDialog.toImgScanDialog(mContext, uri.toString());
        img_qr.setVisibility(View.VISIBLE);
        img_qr.setImageBitmap(CodeUtils.createImage(SystemParamsUtils.getAndroidID(mContext), 400, 400, null));
    }
    
}
